package main

import (
	"fmt"
	"github.com/gogf/gf/util/grand"
)

type Foo2 struct {
	name string
	age  int
}

func main() {
	test()

	a1 := &Foo2{}
	fmt.Printf("%#v", a1)

	var f2 Foo2
	fmt.Println(f2)                   //{ 0}
	fmt.Printf("foo2 --> %#v\n ", f2) //foo2 --> main.Foo2{name:"", age:0}

	p1 := new(int)
	fmt.Printf("p1 --> %#v \n ", p1)           //(*int)(0xc42000e250)
	fmt.Printf("p1 point to --> %#v \n ", *p1) //0

	var p2 *int
	i := 0
	p2 = &i
	fmt.Printf("p2 --> %#v \n ", p2)           //(*int)(0xc42000e278)
	fmt.Printf("p2 point to --> %#v \n ", *p2) //0

	//todo 这种初始化值为nil
	var s1 []int
	if s1 == nil {
		fmt.Printf("s1 is nil --> %#v \n ", s1) // []int(nil)
	}

	//todo 这种初始化，值为初值
	s2 := make([]int, 3)
	if s2 == nil {
		fmt.Printf("s2 is nil --> %#v \n ", s2)
	} else {
		fmt.Printf("s2 is not nill --> %#v \n ", s2) // []int{0, 0, 0}
	}

	rand := grand.N(1, 10)
	fmt.Println(rand)
}

func test() Foo2 {
	return Foo2{}
}
